<template>
  <div>
   <el-tree
    :data="data"
    show-checkbox
    node-key="id"
    :default-expanded-keys="[2, 3]"
    :default-checked-keys="[5]"
    :props="defaultProps"
    @node-click="change"
  />
  </div>
</template>

<script>
import axios from "../../http/axios";
export default {
  data() {
    return {
      data: [],
       defaultProps: {
        children: 'son',
        label: 'name',
      },
    };
  },
  methods: {
    get_data() {
      axios('/dept','get').then(res=>{
          console.log(res)
          this.data=res.list
      })
    },
    change(data){
        // console.log(data)
        this.$emit('getdeptid',data.id)
    }
  },
  mounted() {
    this.get_data();
  },
};
</script>

<style>
</style>